Version: Sep 30, 2025

Setting a Static IP Address on Ubuntu Server

1. Identify Network Interface Details

2. Access Netplan Configuration

3. Back Up the Original Configuration

4. Edit the Configuration File

bash sudo nano /etc/netplan/01-netcfg.yaml - Replace or add the following configuration, substituting with your desired IP, gateway, and DNS:

```yaml network: version: 2 ethernets: eth0: # Replace with your interface name dhcp4: false addresses: - 192.168.1.100/24 # Replace with your desired IP and subnet mask routes: - to: default via: 192.168.1.1 # Replace with your gateway nameservers: addresses: - 8.8.8.8 # Google DNS - 8.8.4.4

  eth1:
    dhcp4: false
    addresses:
    - 10.10.10.1/24       # second NIC, this example is a private network

```

5. Apply Configuration

6. Verify Configuration

7. Troubleshooting

8. Restart Network Services

9. Optional: Enable forwarding

On node 1 bash echo "net.ipv4.ip_forward=1" | sudo tee -a /etc/sysctl.conf sudo sysctl -p

On MacOS workstation - temporary
sudo route -n add 10.10.10.0/24 192.168.1.50
On MacOS workstation - permanent

Create a file

sudo nano /Library/LaunchDaemons/com.local.staticroutes.plist

Add:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN"
  "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
  <dict>
    <key>Label</key><string>com.local.staticroutes</string>
    <key>ProgramArguments</key>
    <array>
      <string>/sbin/route</string>
      <string>-n</string>
      <string>add</string>
      <string>10.10.10.0/24</string>
      <string>192.168.2.50</string>
    </array>
    <key>RunAtLoad</key><true/>
  </dict>
</plist>

Then load it:

sudo launchctl load /Library/LaunchDaemons/com.local.staticroutes.plist

Now it’ll reapply at every boot.

Test it

You should be able to ping the private network, assuming we made node 1 second NIC 10.10.10.1 and node 2 10.10.10.2

ping 10.10.10.2